using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Xml;
namespace WindowsGame1
{
    
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here


            base.Initialize();

                 
        }
        public void CriarXML()
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            XmlWriter escritor = XmlWriter.Create("Save1.xml", settings);
            escritor.WriteStartDocument();
            escritor.WriteStartElement("One_Piece");
            escritor.WriteStartElement("Chapeu_de_Palha");
            escritor.WriteStartElement("Ruffy");
            escritor.WriteString("Comandante");
            escritor.WriteEndElement();
            escritor.WriteStartElement("Zoro");
            escritor.WriteString("Espadaxim 15151");
            escritor.WriteEndElement();
            escritor.WriteStartElement("Sanji");
            escritor.WriteString("Cozinheiro");
            escritor.WriteEndElement();
            escritor.WriteEndElement();
            escritor.WriteEndDocument();
            escritor.Flush();
            escritor.Close();
        }

        
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            CriarXML();

            // TODO: use this.Content to load your game content here
        }
        public void LerXML()
            //aula
        {
            XmlReader reader = XmlReader.Create("Save1.XML");
            //CriarXML();
            //LerXML();
            try
            {
                reader = XmlReader.Create("Save1.XML");
            }
            catch
            {
                CriarXML();
                reader = XmlReader.Create("Save1.XML");

            }
            {
                /*int = it = 0
                while(int < 10);*/
                while (reader.Read())
                {
                    //codico cagou 
                     //reader.ValueType
                    //Console.WriteLine(reader.ValueType);
                    reader.ReadToFollowing("Chapeu_de_Palha");
                    Console.WriteLine(reader.NodeType);
 
                }

            }
                

        }

        
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here

            base.Update(gameTime);
        }

        
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
    }
}
